<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'modif_limits.jsp' starting page</title>
	<META content="MSHTML 6.00.2900.5848" name=GENERATOR>
	<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
	<link href="../css/public.css" rel="stylesheet" style="text/css">
	</HEAD>
	<BODY
		style="BACKGROUND-POSITION-Y: -120px; BACKGROUND-IMAGE: url(../images/background.gif); BACKGROUND-REPEAT: repeat-x">
		<SCRIPT type=text/javascript>
			    var XMLhttp;
		    function createXMLHttpRequest(){
		      if(window.XMLHttpRequest){
		        XMLhttp=new XMLHttpRequest();
		      }
		      else if(window.ActiveXObject){
		      XMLhttp=new ActiveObject();n
		      }
		    
		    }
		    function save(rightId,parentId){
		      createXMLHttpRequest();
		      if(XMLhttp!=null){
		      	var positionId = document.getElementById("emp").value;
		     	if (document.getElementById("child"+rightId).checked) {
				   XMLhttp.open("post","staffAction_staff_update.action?staffId="+positionId+"&moduleId="+rightId+"&parentId="+parentId+"&type=1",true);
			   } else {
			    	
				  XMLhttp.open("post","staffAction_staff_update.action?staffId="+positionId+"&moduleId="+rightId+"&parentId="+parentId+"&type=2",true);
			  }
		        XMLhttp.onreadystatechange=processRequest;
		        XMLhttp.send(); 
		      
		      }
		  function processRequest(){
		  
			if (XMLhttp.readyState == 4) {
						if (XMLhttp.status == 200) {
						  var rtest = XMLhttp.responseText;
						}else{
						
						}
					}
				}
			}    
		function doPostBack() {
			document.position.submit();
		}
	/*	function save(rightId) {
			var positionId = document.getElementById("emp").value;
			if (document.getElementById(rightId).checked) {
				location = "position_rightupdate?staffId=" + positionId
						+ "&modifId=" + rightId + "&type=1";
	
			} else {
				location = "position_rightupdate?staffId=" + positionId
						+ "&modifId=" + rightId + "&type=2";
			}
		}*/
		function changeSn(sn){
	       var id=sn;
	       window.location.href="staffAction_findStaff.action?staffId="+id;
		}
		function jqueryUpdate(rightId,parentId){
		var positionId = document.getElementById("emp").value;
		if (document.getElementById("child"+rightId).checked) {
		$.ajax({
       		   type: "POST",
   			   url: "staffAction_staff_update.action",
               data: "staffId="+positionId+"&moduleId="+rightId+"&parentId="+parentId+"&type=1",
               success: function(){
              }
            });
            }
            else{
            $.ajax({
       		   type: "POST",
   			   url: "staffAction_staff_update.action",
               data: "staffId="+positionId+"&moduleId="+rightId+"&parentId="+parentId+"&type=2",
               success: function(){
              }
            });
            
            }
		}
	</SCRIPT>
		<SCRIPT src="EmployeeMgr.files/WebResource.axd" type=text/javascript></SCRIPT>
		<SCRIPT src="EmployeeMgr.files/ScriptResource.axd"
			type=text/javascript></SCRIPT>
		<SCRIPT src="EmployeeMgr.files/ScriptResource(1).axd"
			type=text/javascript></SCRIPT>
		<DIV>
			<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%"
				border=0>
				<TBODY>
					<TR
						style="BACKGROUND-IMAGE: url(../images/bg_header.gif); BACKGROUND-REPEAT: repeat-x"
						height=47>
						<TD width=10>
							<SPAN
								style="FLOAT: left; BACKGROUND-IMAGE: url(../images/main_hl.gif); WIDTH: 15px; BACKGROUND-REPEAT: no-repeat; HEIGHT: 47px">
							</SPAN>
						</TD>
						<TD>
							<SPAN
								style="FLOAT: left; BACKGROUND-IMAGE: url(../images/main_hl2.gif); WIDTH: 15px; BACKGROUND-REPEAT: no-repeat; HEIGHT: 47px">
							</SPAN>
							<SPAN
								style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FLOAT: left; BACKGROUND-IMAGE: url(../images/main_hb.gif); PADDING-BOTTOM: 10px; COLOR: white; PADDING-TOP: 10px; BACKGROUND-REPEAT: repeat-x; HEIGHT: 47px; TEXT-ALIGN: center; 0 px: ">
								修改权限信息</SPAN><SPAN
								style="FLOAT: left; BACKGROUND-IMAGE: url(../images/main_hr.gif); WIDTH: 60px; BACKGROUND-REPEAT: no-repeat; HEIGHT: 47px"></SPAN>
						</TD>
						<TD
							style="BACKGROUND-POSITION: 50% bottom; BACKGROUND-IMAGE: url(../images/main_rc.gif)"
							width=10></TD>
					</TR>
					<TR>
						<TD style="BACKGROUND-IMAGE: url(../images/main_ls.gif)">
							&nbsp;
						</TD>
						<TD
							style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; COLOR: #566984; PADDING-TOP: 10px; BACKGROUND-COLOR: white"
							vAlign=top align=center>
							<DIV>
								<form action="staffAction_findModuleList.action" method="post"
									name="position">
									<TABLE class=gridView id=ctl00_ContentPlaceHolder2_GridView1
										style="WIDTH: 100%; BORDER-COLLAPSE: collapse" cellSpacing=0
										rules=all border=1 align="center">

										<TBODY>
											<TR>
												<TH class=gridViewHeader scope=col>
												  员工编号
												</TH>
												<TD class=gridViewItem>
												 <s:select id="emp" list="#session.list" listKey="id" listValue="sn" onchange="changeSn(this.value)" theme="simple" value="mstaff.id"></s:select>
												</TD>
											</TR>
											<TR>
												<TH class=gridViewHeader scope=col>
													权限列表
												</TH>
												<TD class=gridViewItem>
													<s:iterator id="test" value="moduleList">
													  <!--父模块 -->
												          <s:set name="moduleflg" scope="request" value="false"> </s:set>
													      <s:iterator value="mstaff.staffandmodules">
								                            <s:if test="module.id==#test.id">
								                               <s:set name="moduleflg" scope="request" value="true"> </s:set>
								                               <s:set name="child"  scope="request" value="module.moduleandsubs"></s:set>
								                            </s:if>
													      </s:iterator>
													        <s:if test="#request.moduleflg">
													      <!--  <input type="checkbox"
																	id="parent<s:property value="#test.id" />"
																	value="<s:property value="#test.id" />"
																	onclick="save('<s:property value="#test.id"/>');"  checked="checked"/> --> 
																<s:property value="name" /><br/>
													        
													        </s:if>
													        <s:else>
																<!-- <input type="checkbox"
																	id="parent<s:property value="id" />"
																	value="<s:property value="id" />"
																	onclick="save('<s:property value="id" />');" /> -->
																<s:property value="name" /><br/>
															</s:else>
															<!-- 子模块 -->
																<s:iterator id="childList" value="submodules">
																  <s:set value="false" scope="request" name="childFlg"></s:set>
															      <s:iterator value="mstaff.staffandmodules">
															        <s:if test="submodule.id==#childList.id">
															         <s:set value="true" scope="request" name="childFlg"></s:set>
															        </s:if>
															      </s:iterator>
																 <s:if test="#request.childFlg">
																  <input type="checkbox"
																	id="child<s:property value="id" />"
																	value="<s:property value="id" />"
																	checked="checked"
																	onclick="jqueryUpdate('<s:property value="id" />','<s:property value="#test.id"/>');" />
																  <s:property value="name" />
																 </s:if>
																 <s:else>
																  <input type="checkbox"
																	id="child<s:property value="id" />"
																	value="<s:property value="id" />"
																	onclick="jqueryUpdate('<s:property value="id" />','<s:property value="#test.id"/>');" />
																  <s:property value="name" />
																   </s:else>
																</s:iterator>
																<br/>
																
													</s:iterator>
												</TD>
											</TR>
											<TR>
												<TH class=gridviewHeader scope=col>
													操作
												</TH>
												<TD class=gridViewItem>
													<A class=cmdField
														id=ctl00_ContentPlaceHolder2_GridView1_ctl02_LinkButton1
														onclick="doPostBack();">修改</A>
												</TD>
											</TR>
										</TBODY>
									</TABLE>
								</form>
							</DIV>
						</TD>
						<TD style="BACKGROUND-IMAGE: url(../images/main_rs.gif)"></TD>
					</TR>
					<TR
						style="BACKGROUND-IMAGE: url(../images/main_fs.gif); BACKGROUND-REPEAT: repeat-x"
						height=10>
						<TD style="BACKGROUND-IMAGE: url(../images/main_lf.gif)"></TD>
						<TD style="BACKGROUND-IMAGE: url(../images/main_fs.gif)"></TD>
						<TD style="BACKGROUND-IMAGE: url(../images/main_rf.gif)"></TD>
					</TR>
				</TBODY>
			</TABLE>
		</DIV>
		<SCRIPT type=text/javascript>
	//         
	Sys.Application.initialize();
	//
</SCRIPT>
</html>
